home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F19010_ComboPull1.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-10-04  |  2.4 KB  |  55 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- ===========================================================
  3.   Category:       HTML
  4.   Sub-category:   ComboBoxes
  5.   Author:         David Silverlight
  6.                   HeadGeek@xmlpitstop.com
  7.   Created:        2001-05-16
  8.   Description:-
  9.     This stylsheet demonstrates how to load the contents of an
  10.     HTML combo box as well as setting the default value.  In
  11.     this example, we store the default value in a variable to
  12.     make the code a bit more reusable.Also note that we are
  13.     using the Pull method to extract data from our xml document.
  14.     The pull method is an approach where the use of templates is
  15.     minimized and data is accessed by "pulling" it
  16.     from our xml document
  17. ================================================================ -->
  18. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  19.   <xsl:output method="html" encoding="ISO-8859-1" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN" />
  20.  
  21.   <xsl:template match="/">
  22.     <html>
  23.       <head>
  24.         <style type="text/css">
  25.         H1 {COLOR: red; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
  26.         H2 {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  27.         .head {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
  28.         .subhead {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  29.         .text {COLOR: black; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  30.         TH {COLOR: white; FONT-FAMILY: Arial; background-color: darkblue;}
  31.         TD {COLOR: darkblue; FONT-FAMILY: Arial}
  32.         TR { background-color: beige; }
  33.         BODY { background-color: beige; }
  34.         </style>
  35.       </head>
  36.       <body>
  37.         <span class="subhead">Loading an HTML combo box from xml (Using the Pull approach)</span>
  38.         <br />
  39.         <xsl:variable name="cmbDefault" select="'AROUT'" />
  40.         <SELECT id="cmbCompanies" name="cmbCompanies">
  41.           <xsl:for-each select="customers/customer">
  42.             <xsl:element name="OPTION">
  43.               <!--Make sure that the default value is highlighted -->
  44.               <xsl:if test="@CustomerID = $cmbDefault">
  45.                 <xsl:attribute name="selected" />
  46.               </xsl:if>
  47.               <!-- Set the value for the combo box -->
  48.               <xsl:value-of select="@CompanyName" />
  49.             </xsl:element>
  50.           </xsl:for-each>
  51.         </SELECT>
  52.       </body>
  53.     </html>
  54.   </xsl:template>
  55. </xsl:stylesheet>